package com.mingqijia.gassafety.shared.constant;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author zhangfei
 * @version 1.0.0
 * @ClassName PageListCode.java
 * @Description TODO
 * @createTime 2023年09月28日
 */
@Getter
@RequiredArgsConstructor
public enum ListCodeCategoryEnum {

    CUSTOMER_LIST("CUSTOMER_LIST","客户列表"),
    TEAL_TIME_MONITORING("TEAL_TIME_MONITORING","实时监测"),
    ALARM_RECORD("ALARM_RECORD","报警记录"),
    WARNING_DATA("WARNING_DATA","告警数据"),
    BREAKDOWN_RECORD("BREAKDOWN_RECORD","故障记录"),
    EQUIPMENT_LIST("EQUIPMENT_LIST","设备列表"),
    MAINTAIN_RECORD("MAINTAIN_RECORD","维护记录"),
    CUSTOMER_MANAGE("CUSTOMER_MANAGE","客户管理"),
    CUSTOMER_MANAGE_DETAIL("CUSTOMER_MANAGE_DETAIL","客户管理-详情-关联设备"),
    OTHER("","");

    private final String code;
    private final String alias;
    public static ListCodeCategoryEnum parse(String code) {
        List<ListCodeCategoryEnum> filtered = Arrays.stream(ListCodeCategoryEnum.values())
                .filter(item ->
                        Objects.equals(item.getCode(), code))
                .collect(Collectors.toList());
        return CollectionUtils.isEmpty( filtered ) ? OTHER : filtered.get(0);
    }
}